<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>测试jsonp和跨域post调用</title>
    <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
</head>
<body>

<input type="text" id="aa" name="aa" value=""><br/>
<textarea id="largeData" name="largeData" rows="5" cols="30"></textarea><br/>
<input type="submit" value="cros post" name="aaaaasdf" id="submit"><br/>
<input type="submit" value="jsonp get" name="aaaaasdf" id="submit2">

<script type="text/javascript">
    $("#submit").click(function () {
        $.ajax({
            url: 'http://localhost:8080/hello/crosPost',
//            contentType: "application/x-www-form-urlencoded",
            type: 'POST',
            data: {a: $("#aa").val(), 'largeData': $("#largeData").val()},
            success: function (data) {
                alert(data);
            }
        })
    });

    $("#submit2").click(function () {
        $.ajax({
            url: 'http://localhost:8080/hello/jsonpGet',
//            contentType: "application/x-www-form-urlencoded",
            dataType: 'jsonp',
            type: 'GET',
            data: {a: $("#aa").val(), 'largeData': $("#largeData").val()},
            success: function (data) {
                alert(data);
            }
        })
    });

</script>

</body>
</html>